import {getCookie} from "../../utils/cookie";
import myalert from "../../utils/myalert";

export default function Auth(component) {
    if (typeof component == "function") {
        return {
            mounted() {
                //判断是否登录
                if (getCookie('app.login_user')) {
                    //有
                } else {
                    var self = this
                    myalert.fail("没有登录")
                    setTimeout(() => {
                        self.$router.replace("/login")
                    }, 300)
                }
            },
            extends: component(),
        }
    } else {
        return {
            mounted() {
                //判断是否登录
                if (getCookie('app.login_user')) {
                    //有
                } else {
                    var self = this
                    myalert.fail("没有登录")
                    setTimeout(() => {
                        self.$router.replace("/login")
                    }, 300)
                }
            },
            extends: component,
        }
    }

}